package com.cloud.layuimini.controller;

import cn.hutool.core.io.resource.ClassPathResource;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.nio.charset.StandardCharsets;

@Controller
public class Home {

    @GetMapping("/")
    public String home(){
        return "index.html";
    }

    @GetMapping("/menu")
    @ResponseBody
    public JSONObject menu() {
        ClassPathResource resource = new ClassPathResource("static/api/init.json");
        JSONObject jsonObject = JSONUtil.readJSONObject(resource.getFile(), StandardCharsets.UTF_8);
        return jsonObject;
    }
}
